import java.util.Scanner;

public class P1047 {
    public static void main(String[] args) {
        int l,m;
        int[] arr = new int[1000000];
        int u,v;
        int count=0;
        Scanner sc = new Scanner(System.in);
        l = sc.nextInt();
        m = sc.nextInt();
        for(int i=0; i<=l; i++) {
            arr[i] = 1;
        }
        for(int i=1; i<=m; i++) {
            u = sc.nextInt();
            v = sc.nextInt();
            for(int j=u; j<=v; j++) {
                arr[j]=0;
            }
        }

        for(int i=0; i<=l; i++) {
            if(arr[i]==1) {
                count++;
            }
        }
        System.out.println(count);
    }
}
